/**
 * @Date 2023-02-21 10:03:49
 * @Remark
 */

// react
import React from "react";
// lib
import { Space, Button, Popconfirm } from "antd";
// components & widget
// style
// config
import { MODULE_NAME } from "./config";
// script & methods & public
// store
import { state } from "./state";
// controller
import { delRole } from "./controller";
import { showPermissionModal } from "./PermissionModal/controller";
// interface
// 其它

const TableColumns = [
  {
    title: "角色Id",
    dataIndex: "id",
  },
  {
    title: "角色名称",
    dataIndex: "name",
  },
  // {
  //   title: "角色编码",
  //   dataIndex: "roleCode",
  // },
  {
    title: "角色描述",
    dataIndex: "description",
  },
  // {
  //   title: "是否启用",
  //   dataIndex: "locked",
  //   render: (lk: boolean) => {
  //     return lk ? "启用" : "未启用";
  //   },
  // },
  // {
  //   title: "创建时间",
  //   dataIndex: "gmtCreate",
  // },
  // {
  //   title: "修改时间",
  //   dataIndex: "gmtModified",
  // },
  {
    title: "操作",
    key: "action",
    fixed: "right" as any,
    render: (el: RoleDto) => {
      const edit = () => {
        state.editModal = el;
      };
      const del = () => {
        delRole(el.id);
      };
      // const menu = () => {
      //   showMenuModal(el);
      // };
      const permission = () => {
        showPermissionModal(el);
      };

      return (
        <Space>
          {/* <Button size="small" type="primary" ghost onClick={menu}>
            菜单
          </Button> */}
          <Button size="small" type="primary" ghost onClick={permission}>
            权限
          </Button>
          <Button size="small" type="primary" ghost onClick={edit}>
            编辑
          </Button>
          <Popconfirm
            title={`确定删除${MODULE_NAME} ${el.name}?`}
            onConfirm={del}
          >
            <Button size="small" danger ghost>
              删除
            </Button>
          </Popconfirm>
        </Space>
      );
    },
  },
];

export default TableColumns;
